package com.nbjtjc.safe.api.danger;

import com.nbjtjc.common.validator.ValidatorUtils;
import com.nbjtjc.common.validator.group.UpdateGroup;
import com.nbjtjc.safe.annotation.SysLog;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.danger.DangerDistribute;
import com.nbjtjc.safe.model.danger.DangerInspect;
import com.nbjtjc.safe.service.danger.DangerDistributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @auther guqianbin
 * @date 2018/4/11 15:41
 **/
@RestController
@RequestMapping("/danger/distribute")
@CrossOrigin("*")
public class DangerDistributeController {
    @Autowired
    private DangerDistributeService dangerDistributeService;

    @SysLog("添加派单")
    @RequestMapping(value = "/add", method = {RequestMethod.POST})
    public Result add(@RequestBody DangerDistribute dangerDistribute) {
        ValidatorUtils.validateEntity(dangerDistribute);
        Result  result=dangerDistributeService.add(dangerDistribute);
        return result;
    }
    @SysLog("删除派单")
    @RequestMapping(value = "/delete", method = {RequestMethod.POST})
    public Result delete(@RequestBody DangerDistribute dangerDistribute) {
        ValidatorUtils.validateEntity(dangerDistribute, UpdateGroup.class);
        Result result =dangerDistributeService.delete(dangerDistribute);
        return result;
    }

    @SysLog("更新派单")
    @RequestMapping(value = "/update", method = {RequestMethod.POST})
    public Result update(@RequestBody DangerDistribute dangerDistribute) {
        ValidatorUtils.validateEntity(dangerDistribute,UpdateGroup.class);
        Result result = dangerDistributeService.update(dangerDistribute);
        return result;
    }

    @RequestMapping(value = "/find", method = {RequestMethod.POST})
    public Result find(@RequestBody DangerDistribute dangerDistribute) {
        Result result =dangerDistributeService.find(dangerDistribute);
        return result;
    }
}
